<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" rel="stylesheet" type="text/css" media="all" />
	<link href="<?php echo Yii::app()->request->baseUrl; ?>/css/new_style.css" rel="stylesheet" type="text/css" media="all" />
	<link href="<?php echo Yii::app()->request->baseUrl; ?>/css/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" media="all" />
	<!--[if IE]>
		<link href='<?php echo Yii::app()->request->baseUrl; ?>/css/ie7.css' rel='stylesheet' type='text/css' media='all' />
	<![endif]-->
	<?php
	Yii::app ()->clientScript->registerScriptFile ( '/js/jquery.js' );
	Yii::app ()->clientScript->registerScriptFile ( '/js/jquery-ui-1.8.17.custom.min.js' ); 
	Yii::app ()->clientScript->registerScriptFile ( "/js/jquery-ui-1.8.16.custom.min.js" );
	Yii::app ()->clientScript->registerScriptFile ( "/js/cusel.js" );
	Yii::app ()->clientScript->registerScriptFile ( "/js/jScrollPaneCusel.js" );
	Yii::app ()->clientScript->registerScriptFile ( "/js/jScrollPane.js" );
	Yii::app ()->clientScript->registerScriptFile ( "/js/jquery.mousewheel.js" );
	Yii::app ()->clientScript->registerScriptFile ( "/js/audio/audio.min.js" );
	Yii::app ()->clientScript->registerScriptFile ( "/js/fns.js" );
	Yii::app ()->clientScript->registerScriptFile ( "/js/ajaxfileupload.js" );
	?>
	
	
	<title><?php echo CHtml::encode($this->pageTitle); ?></title>
</head>
<body>
<p id="warningMsg"></p>
<?php /*<a id="backBtn" href="/">Вернутся</a>*/?>
<a id="topBtn" href="/">Вверх</a>
<div id="music">
	<div class="panel">
		<div class="volumePanel">
			<div class="volume_icon"></div>
			<div id="audioSlider"></div>
		</div>
		
		<!-- <a href="#" class="clearPlayer">Очистить</a> -->
		<a href="#" class="closePlayer">Закрыть</a>
	</div>
	<div class="musicInner">
		<audio></audio>
	</div>
</div>
<div id="popup" class="hidden">
	<div id="fade">
	<div class="popup_reduser"></div>
	</div>
</div>
<div id="layout">
	<?php if (!Yii::app()->user->isGuest) : ?>
	<div id="header">
		<div class="reduser">
			<div class="l_sh"></div>
			<div class="r_sh"></div>
				<div class="l user_action_l">
					<div class="user_action_item">
						<a href="<?php echo Yii::app()->createUrl('messages/index', array('profile'=>Yii::app()->user->id));?>" class="user_action_item_icon i1" id="check_new_message" rel="<?php echo Yii::app()->createAbsoluteUrl("messages/checkmessage"); ?>"></a>
						<?php 		
						$messages = Messages::model()->findAll(array(
							'condition'=>'`to`=:user AND `status_to` = 1 AND `read` = 0',
							'params'=>array(':user'=>Yii::app()->user->id)
						)); 

						if(count($messages)){ ?>
							<div class="user_action_item_new">+<?php echo count($messages); ?></div>
							<div class="user_action_item_tooltip c hidden"><div class="cc"><?php echo count($messages); ?> новых сообщений</div></div>
						<?php }else{ ?>
							<div class="user_action_item_new hidden"></div>
							<div class="user_action_item_tooltip c hidden"><div class="cc">Нет новых сообщений</div></div>						
						<?php } ?>
					</div>
					<div class="user_action_item">
						<a href="<?php echo Yii::app()->createUrl('messages/index', array('profile'=>Yii::app()->user->id));?>" class="user_action_item_icon i2" id="check_new_dialog" rel="<?php echo Yii::app()->createAbsoluteUrl("messages/checkdialog"); ?>"></a>
						<?php 		
						$dialogs = Messages::checkDialogs();

						if(count($dialogs)){ ?>						
							<div class="user_action_item_new">+<?php echo count($dialogs); ?></div>
							<div class="user_action_item_tooltip c hidden"><div class="cc"><?php echo count($dialogs); ?> новых диалогов</div></div>
						<?php }else{ ?>
							<div class="user_action_item_new hidden"></div>
							<div class="user_action_item_tooltip c hidden"><div class="cc">Нет новых диалогов</div></div>						
						<?php } ?>
					</div>
					<div class="user_action_item">
						<a href="<?php echo Yii::app()->createUrl('people/index', array('tab'=>'requestFriends', 'profile'=>Yii::app()->user->id));?>" class="user_action_item_icon i3" id="check_request_friend" rel="<?php echo Yii::app()->createAbsoluteUrl("profile/checkrequestfriend"); ?>"></a>
						<?php 
						$countData = Friends::model()->countFriends(array(
							'status' => 0,
							'friend_id' => Yii::app()->user->id
						));
						if($countData['total']){ ?>
							<div class="user_action_item_new">+<?php echo $countData['total']; ?></div>
							<div class="user_action_item_tooltip c hidden"><div class="cc"><?php echo $countData['total']; ?> запросов на дружбу</div></div>						
						<?php }else{ ?>
							<div class="user_action_item_new hidden"></div>
							<div class="user_action_item_tooltip c hidden"><div class="cc">Нет запросов на дружбу</div></div>
						<?php } ?>
					</div>
				</div>
				<div class="r">
					<div class="login_block">
						<div class="logout"><a href="<?php echo Yii::app()->createUrl('site/logout');?>"></a></div>
						<a href="<?php echo Yii::app()->createUrl('site/logout');?>" class="userpic">
							<?php echo $this->material_image(0, Yii::app()->user->getState('avatar'), '37', 'photos/'. Yii::app()->user->id . '/' . 0); ?>
						</a>
					</div>
					<ul class="user_action_menu">
						<li><a href="<?php echo Yii::app()->createUrl('people/index', array('profile'=>Yii::app()->user->id));?>">Люди</a></li>
						<li><a href="<?php echo Yii::app()->createUrl('groups/index', array('profile'=>Yii::app()->user->id));?>">Сообщества</a></li>
						<li><a href="<?php echo Yii::app()->createUrl('audio/index', array('profile'=>Yii::app()->user->id));?>">Аудиозаписи</a></li>
						<li><a href="<?php echo Yii::app()->createUrl('video/index', array('profile'=>Yii::app()->user->id));?>">Видеозаписи</a></li>
						<li><a href="<?php echo Yii::app()->createUrl('albums/index', array('profile'=>Yii::app()->user->id));?>">Фото</a></li>
					</ul>
				</div>
		</div>
		<div class="clear"></div>
	</div>
	<?php else: ?>
	<div id="header">
		<div class="reduser">
			<div class="l_sh"></div>
			<div class="r_sh"></div>
			<div class="r guest">
				<ul class="nouser_action_menu">
					<li><a href="<?php echo Yii::app()->createUrl('site/login');?>">Войти</a></li>
					<li><a href="<?php echo Yii::app()->createUrl('site/registration');?>">Зарегестрироватся</a></li>
				</ul>
			</div>
		</div>
		<div class="clear"></div>
	</div>
	<?php endif; ?>
	<!--основная часть-->
	<div id="container">
		<div class="reduser">
			<div class="c_head">
				<div class="l">
					<a href="/" id="logo"><img src="/images/logo.gif" width="146" height="41" border="0" alt="" /></a>
				</div>
				<?php if (!Yii::app()->user->isGuest) : ?>
				<div class="r">
					<div class="search_block">
						<form action="<?php echo Yii::app()->createUrl('search/index'); ?>" rel="<?php echo Yii::app()->createUrl('search/index'); ?>" method="get" id="main_search">
							<div class="search_btn btn"><input type="submit" value="Найти" id="main_search_button" /></div>
							<div class="search_fld">
								<div class="search_icon"></div>
								<input type="text" name="text" value="" placeholder="Найти друзей, сообщества, аудио, видео" id="main_search_text" />
								<input type="hidden" name="tab" value="<?php echo $this->uniqueid; ?>" />
								<a href="<?php echo Yii::app()->createUrl('search/index');?>" class="search_more_link">Расширенный поиск</a>
							</div>
						</form>
					</div>
				</div>
				<?php endif; ?>
			</div>
    		<?php echo $content; ?>
    	</div>
    </div>
	<div id="footer_spacer"></div>
	<div id="footer">
		<div class="reduser">
			<p class="copy">© Социальная сеть “ВЧЕЧНЕ.РУ”, 2012<br />
			<a href="<?php echo Yii::app()->createUrl('site/contact');?>" class="ajaxLink">Сообщить о злоупотреблении</a></p>
			<div class="made">
				<a href="http://garipovv.com/" class="autor_link">
					<span class="autor_link_logo"></span>
					GaripovGroup
				</a>
				<p>Сделано в</p>
			</div>
		</div>
	</div>
</div>


</body>
</html>